package com.example.java;

/**
 * ClassName: Demo
 * Package: com.example.java
 * Description:
 *
 * @Author 尚硅谷-宋红康
 * @Create 2025/7/9 9:39
 * @Version 1.0
 */
public class Demo {
    public static void main(String[] args) {
        Student student = new Student();
        System.out.println("构造完成，已回到主函数");
        System.out.println("姓名："+student.name+"；性别："+student.gender+"；年龄："+student.age);

    }
}

class Student extends People {
    int id;
    String school;
    int grade;

    //构造代码块
    {
        System.out.println("===========================");
        System.out.println("父类初始化已经结束，当前：\n姓名："+this.name+"；性别："+this.gender+"；年龄："+this.age);
        System.out.println("子类构造代码块开始"+"\n");
        this.name = "李四";
        this.gender = "女";
        this.age = 20;
        System.out.println("子类构造代码块即将结束，\n姓名："+this.name+"；性别："+this.gender+"；年龄："+this.age);
        System.out.println("===========================");
    }

    public Student(){
        //隐式super()   调用父类的构造器,然后
        System.out.println("===========================");
        System.out.println("子类构造代码块已经结束，当前：\n姓名："+this.name+"；性别："+this.gender+"；年龄："+this.age);
        System.out.println("子类的【构造器显式赋值】开始"+"\n");
        this.name = "李四点五";
        this.gender = "春哥";
        this.age = 666;
        System.out.println("子类初始化结束，\n姓名："+this.name+"；性别："+this.gender+"；年龄："+this.age);
        System.out.println("===========================");
    }

//    public Student(int id, String school, int grade) {
//        this.id = id;
//        this.school = school;
//        this.grade = grade;
//    }

}

class People{
    String name = "张三";
    String gender = "男";
    int age = 25;
    {
        System.out.println("父类的声明变量显式赋值已完成，当前：\n姓名："+this.name+"；性别："+this.gender+"；年龄："+this.age);
    }

    public People() {
        System.out.println("===========================");
        System.out.println("父类【构造器显式赋值】开始，当前：\n姓名："+this.name+"；性别："+this.gender+"；年龄："+this.age+"\n");
        this.name = "张三点五";
        this.gender = "神仙";
        this.age = 999;
        System.out.println("父类初始化即将结束，\n姓名："+this.name+"；性别："+this.gender+"；年龄："+this.age);
        System.out.println("===========================");
    }

//    public People(String name, String gender, int age) {
//        System.out.println("父类？？？开始，（构造器？构造器中的显式赋值语句？）\n姓名："+this.name+"性别："+this.gender+"年龄："+this.age);
//        this.name = name;
//        this.gender = gender;
//        this.age = age;
//        System.out.println("父类初始化即将结束，\n姓名："+this.name+"性别："+this.gender+"年龄："+this.age);
//    }
}